package com.lvshi0797.cms.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lvshi0797.cms.dto.AppInfo;
import com.lvshi0797.cms.dto.ProjectDto;
import com.lvshi0797.cms.entities.FBaseInfo;
import com.lvshi0797.cms.entities.FManager;
import com.lvshi0797.cms.service.IBaseInfoService;
import com.lvshi0797.cms.service.IManagerService;
import com.lvshi0797.cms.web.AppInfoUtil;

@Controller
@RequestMapping("admin")
public class AdminController {
	@Autowired
	private IBaseInfoService baseInfoService;
	@Autowired
	private IManagerService managerService;
	
	@RequestMapping("index")
	public String index(Model model) {
		AppInfo appInfo = AppInfoUtil.getInstacne().read();
		model.addAttribute("appInfo", appInfo);
		return "admin";
	}

	@RequestMapping("list")
	public String list() {
		System.out.println("info list.....");
		return "info/list";
	}
	@RequestMapping("all")
	public String all(Model model,HttpSession session) {
		return "info/all";
	}
	@RequestMapping("welcome")
	public String welcome(HttpSession session){
		return "info/welcome";
	}
	 

	@RequestMapping("detail/{id}")
	public String detail(@PathVariable int id,Model model,HttpSession session) {
		FBaseInfo baseInfo = baseInfoService.loadBaseInfo(id);
		ProjectDto project2015 = baseInfoService.getProjects(id,"2015");
		ProjectDto project2016 = baseInfoService.getProjects(id,"2016");
		ProjectDto project2017 = baseInfoService.getProjects(id,"2017");
		ProjectDto project2018 = baseInfoService.getProjects(id,"2018");
		model.addAttribute("baseInfo", baseInfo);
		model.addAttribute("project2015", project2015);
		model.addAttribute("project2016", project2016);
		model.addAttribute("project2017", project2017);
		model.addAttribute("project2018", project2018);
		return "info/detail";
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
}
